package com.thinkgem.jeesite.common.web;

import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.sys.utils.ResponseEnum;

/**
 * 
 * @ClassName:  BusinessException   
 * @Description:  自定义的业务异常 
 * @author: 胡章林
 * @date:   2017年8月19日 下午6:25:02   
 *     
 * @Copyright:
 */
public class BusinessException extends Exception {


	/**
	 * 
	 */
	private static final long serialVersionUID = -1718957020938248906L;
	
	public static final Integer DEFAULT_ERROR_CODE = ResponseEnum.bussiness_error .getCode();
	
	public static final String DEFAULT_ERROR_MESSAGE = ResponseEnum.bussiness_error .getMessage();
	
	private Integer code ;
	
	private String message ;
	
	
	
	public BusinessException() {
		super();
		defalutResponse();
	}

	

	public BusinessException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
		super(message, cause, enableSuppression, writableStackTrace);
		defalutResponse();
	}

	public BusinessException(String message, Throwable cause) {
		super(message, cause);
		defalutResponse();
	}

	public BusinessException(String message) {
		super(message);
		 
	}

	public BusinessException(Throwable cause) {
		super(cause);
		defalutResponse();
	}

	public BusinessException(Integer code, String message) {
		super();
		this.code = code;
		this.message = message;
	}
	
	private void defalutResponse() {
		message = StringUtils.isEmpty(message)?DEFAULT_ERROR_MESSAGE:message;
		code = null == code?DEFAULT_ERROR_CODE:code;
	}
	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	

}
